﻿using Dynamitey.DynamicObjects;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Coldairarrow.Util
{
    public static class GlobalAssemblies
    {
        /// <summary>
        /// 解决方案所有程序集
        /// </summary>
        public static readonly Assembly[] AllAssemblies = new Assembly[]
        {
            Assembly.Load("Coldairarrow.Util"),
            Assembly.Load("Coldairarrow.Entity"),
            Assembly.Load("Coldairarrow.IBusiness"),
            Assembly.Load("Coldairarrow.Business"),
            Assembly.Load("Coldairarrow.Api"),
        };

        /// <summary>
        /// 解决方案所有自定义类
        /// </summary>
        public static readonly Type[] AllTypes = AllAssemblies.SelectMany(x => x.GetTypes()).ToArray();

        /// <summary>
        /// 超级管理员UserIId
        /// </summary>
        public const string ADMINID = "Admin";

        /// <summary>
        /// 多平台已经推送的订单列表
        /// </summary>
        private static Dictionary<string, string> PushOrderList_ = new Dictionary<string, string>();
        //众包仓已推送的单号列表
        public static Dictionary<string, string> PushOrderList
        {
            get {
                if (PushOrderList_.Count >= 1000)
                {
                    int countToRemove = 500; // 假设我们要删除最后n项
                    List<string> keysToRemove = PushOrderList_.Keys.Take(countToRemove).Reverse().ToList(); // 获取要删除的键的列表并反转，因为我们想从末尾开始删除
                    keysToRemove.ForEach(key => PushOrderList_.Remove(key)); // 删除这些键
                }
                return PushOrderList_; 
            }
            set { PushOrderList_ = value; 
            
            }
        }



        /// <summary>
        /// 多平台已经推送的订单列表
        /// </summary>
        private static Dictionary<string, string> ZBPushOrderList_ = new Dictionary<string, string>();
        //众包仓已推送的单号列表
        public static Dictionary<string, string> ZBPushOrderList
        {
            get
            {
                if (ZBPushOrderList_.Count >= 1000)
                {
                    int countToRemove = 500; // 假设我们要删除最后n项
                    List<string> keysToRemove = ZBPushOrderList_.Keys.Take(countToRemove).Reverse().ToList(); // 获取要删除的键的列表并反转，因为我们想从末尾开始删除
                    keysToRemove.ForEach(key => ZBPushOrderList_.Remove(key)); // 删除这些键
                }
                return ZBPushOrderList_;
            }
            set
            {
                ZBPushOrderList_ = value;

            }
        }


        /// <summary>
        /// 多平台已经推送的订单列表
        /// </summary>
        private static Dictionary<string, string> REPushList_ = new Dictionary<string, string>();
        //飞熊仓仓已推送的单号列表
        public static Dictionary<string, string> REPushList
        {
            get
            {
                if (REPushList_.Count >= 1000)
                {
                    int countToRemove = 500; // 假设我们要删除最后n项
                    List<string> keysToRemove = REPushList_.Keys.Take(countToRemove).Reverse().ToList(); // 获取要删除的键的列表并反转，因为我们想从末尾开始删除
                    keysToRemove.ForEach(key => REPushList_.Remove(key)); // 删除这些键
                }
                return REPushList_;
            }
            set
            {
                REPushList_ = value;

            }
        }

    }
}
